<{include file = '../include/header.html'}>

<div class="layout-breadcrumb">
	<ol class="breadcrumb">
		<li class="breadcrumb-item"><a href="<{url('index','index')}>">首页</a></li>
		<li class="breadcrumb-item active"><{$forum.name}></li>
	</ol>
</div>
<div class="layout-container">
	<div class="media border p-3">
		<img src="<{$forum.icon}>" alt="版块图标" class="mr-3 rounded" style="width:60px;">
		<div class="media-body">
			<h4><{$forum.name}></h4>
			<span class="float-right">
				<a href="<{url('thread','create',$p_0)}>"><button class="btn btn-info"><i class="fa fa-pencil-square-o"></i> 发表主题</button></a>
			</span>
			<p>
				<b>热度</b> <{$forum.hot}>&nbsp;&nbsp;
				<b>话题</b> <{$forum.threads}>
			</p>
			<p>
				<{($forum.description) ? $forum.description : '这个版块没有描述'}>
			</p>
			<hr>
			<div>
				<h5>版主</h5>
				<{foreach from = $forum.moderators item = $user}>
				<a href="<{url('user','index',$user.uid)}>" data-toggle="tooltip" title="<{$user.username}>"><img src="<{$user.avatar}>" class="mr-3 border rounded-circle" width="50px"></a>
				<{/foreach}>
			</div>
			<hr>
			<div>
				<h5>版规</h5>
				<div id="rule"><{$forum.rule}></div>
			</div>
		</div>
	</div>
	<div class="mt-3">
	    <ul class="nav">
            <li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,0,$p_2)}>" id="sort-0">最新回复</a>
            </li>
			<li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,1,$p_2)}>" id="sort-1">最新发布</a>
            </li>
			<li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,2,$p_2)}>" id="sort-2">浏览最多</a>
            </li>
			<li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,3,$p_2)}>" id="sort-3">评论最多</a>
			</li>
			<li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,4,$p_2)}>" id="sort-4">点赞最多</a>
			</li>
			<li class="nav-item">
                <a class="nav-link" href="<{url('forum','index',$p_0,5,$p_2)}>" id="sort-5">精华</a>
            </li>
		</ul>
		<{foreach from = $threads item = $thread}>
		<div class="card mb-4 thread" onclick="location.href='<{url('thread','index',$thread.tid,0,0,1)}>'">
            <div class="card-body">
                <h5 class="card-title">
					<{if $thread.top == 1}>
					<span class="badge badge-secondary">置顶</span>
					<{else if $thread.top == 2}>
					<span class="badge badge-dark">公告</span>
					<{/if}>
					
					<{if $thread.points}>
					<span class="badge badge-danger"><{number($thread.points)}></span>
					<{/if}>
					<{if time() - $thread.time <= 12 * 60 * 60}>
					<span class="badge badge-success">最新</span>
					<{/if}>
					<{if $thread.comments >= 200}>
					<span class="badge badge-danger">热门</span>
					<{/if}>
					<{if $thread.essence}>
					<span class="badge badge-warning text-light">精华</span>
					<{/if}>
					<{if $thread.lock}>
					<span class="badge badge-info">锁定</span>
					<{/if}>
                    
                    <span><{$thread.title}></span>
                </h5>
                <h6 class="card-subtitle mb-2 mt-2"><{$thread.user.username}></h6>
                <p class="card-text thread-content"><{$thread.content}></p>
                <p class="card-text">
                    <small class="text-muted">
                        <span>发表时间：<{timeFormat($thread.time)}></span>
                        <span class="float-right">
                            浏览：<{$thread.views}>
                            点赞：<{$thread.praises}>
                            评论：<{$thread.comments}>
                        </span>
                    </small>
                </p>
            </div>
        </div>
		<{/foreach}>
		<div>
			<{pagination($forum.threads,30,$p_2,url('forum','index',$p_0,$p_1,'{{page}}'))}>
		</div>
	</div>
</div>

<script>
$(document).ready(function(){
	$('[data-toggle="tooltip"]').tooltip(); 
});

$('#sort-<{$p_1}>').addClass('disabled');
</script>

<{include file = '../include/footer.html'}>